<?php

use backend\widgets\Bar;
use backend\grid\CheckboxColumn;
use backend\grid\ActionColumn;
use backend\grid\GridView;
use yii\widgets\Pjax;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\UserConsumptionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title                   = 'User Consumptions';
$this->params['breadcrumbs'][] = yii::t('app', 'User Consumption');
?>
<div class="row">
    <div class="col-sm-12">
        <div class="ibox">
            <?= $this->render('/widgets/_ibox-title') ?>
            <div class="ibox-content">
                <?= Bar::widget() ?>
                <?= $this->render('_search', ['model' => $searchModel]); ?>
                <?php Pjax::begin(); ?>            <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel'  => $searchModel,
                    'columns'      => [
                        ['class' => CheckboxColumn::className()],

                        'id',
                        [
                            'attribute' => 'uid',
                            'label'     => '用户',
                            'value'     => function ($model) {
                                return $model->u->username;
                            }
                        ],
                        [
                            'attribute' => 'order_id',
                            'value'     => function ($model) {
                                return $model->order->order_id;
                            }
                        ],
                        'money',
                        [
                            'attribute' => 'type',
                            'filter'    => \common\libs\Constants::getUserConsumptionType(),
                            'value'     => function ($model) {
                                return \common\libs\Constants::getUserConsumptionType($model->type);
                            }
                        ],
                        'created_at:datetime',

                        ['class' => ActionColumn::className(),],
                    ],
                ]); ?>
                <?php Pjax::end(); ?>            </div>
        </div>
    </div>
</div>
